//找出出现最多的字符，并记录位置
function myResult() {

    var result;//保存结果
    var arr = ["a", "x", "b", "d", "m", "a", "k", "m", "p", "j", "a", "x", "x", "j", "j"];
    var count = {};//存放统计出现次数的对象
    var position = {};//记录出现位置对方

    //遍历arr，统计每个字母出现次数且记录位置
    arr.forEach(function (value, index) {

        if (count[value]) {
            count[value]++;
            position[value] += "," + index;
        } else {
            count[value] = 1;
            position[value] = "" + index;
        }
    });

    //输出日志
    console.log(count);
    console.log(position);

    //获取出现最多的字母
    var max = 0;
    var letter = [];//保存出现最多的字母
    for (i in count) {
        if (count[i] > max) {
            letter = [];//清空
            max = count[i];
            letter.push(i);
        } else if (count[i] == max) {
            //如果存在两个以上（或以上）
            letter.push(i)
        }
    }

    console.log("出现最多的是：" + letter);

    result = "运算结果:<br/>" + "出现最多的是：" + letter + "<br/>";

    //分布位置
    letter.forEach(function (value, index) {
        console.log(value + "位置分布：" + position[value]);
        result = result + value + "位置分布下标为：" + position[value] + "<br/>";
    });

    //显示结果
    document.getElementById('result').innerHTML = result;
}